package com.ruoyi.security.service.impl;

import cn.hutool.core.util.IdUtil;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.security.domain.AfScheduling;
import com.ruoyi.security.mapper.AfSchedulingMapper;
import com.ruoyi.security.service.IAfSchedulingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 排班Service业务层处理
 *
 * @author cjie
 * @date 2021-07-24
 */
@Service
public class AfSchedulingServiceImpl implements IAfSchedulingService {
    @Autowired
    private AfSchedulingMapper afSchedulingMapper;

    /**
     * 查询排班
     *
     * @param id 排班ID
     * @return 排班
     */
    @Override
    public AfScheduling selectAfSchedulingById(String id) {
        return afSchedulingMapper.selectAfSchedulingById(id);
    }

    /**
     * 查询排班列表
     *
     * @param afScheduling 排班
     * @return 排班
     */
    @Override
    public List<AfScheduling> selectAfSchedulingList(AfScheduling afScheduling) {
        return afSchedulingMapper.selectAfSchedulingList(afScheduling);
    }

    /**
     * 新增排班
     *
     * @param afScheduling 排班
     * @return 结果
     */
    @Override
    public int insertAfScheduling(AfScheduling afScheduling) {
        afScheduling.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        afScheduling.setCreateTime(DateUtils.getNowDate());
        afScheduling.setCreateBy(SecurityUtils.getUsername());
        return afSchedulingMapper.insertAfScheduling(afScheduling);
    }

    /**
     * 修改排班
     *
     * @param afScheduling 排班
     * @return 结果
     */
    @Override
    public int updateAfScheduling(AfScheduling afScheduling) {
        afScheduling.setUpdateTime(DateUtils.getNowDate());
        afScheduling.setUpdateBy(SecurityUtils.getUsername());
        return afSchedulingMapper.updateAfScheduling(afScheduling);
    }

    /**
     * 批量删除排班
     *
     * @param ids 需要删除的排班ID
     * @return 结果
     */
    @Override
    public int deleteAfSchedulingByIds(String[] ids) {
        return afSchedulingMapper.deleteAfSchedulingByIds(ids);
    }

    /**
     * 删除排班信息
     *
     * @param id 排班ID
     * @return 结果
     */
    @Override
    public int deleteAfSchedulingById(String id) {
        return afSchedulingMapper.deleteAfSchedulingById(id);
    }
}
